import request from '@/utils/request';

// 获取积分商品兑换列表
export const getPointsExchangePage = (params) => {
  return request({
    url: '/points/goods/exchange/page',
    method: 'get',
    params
  });
};

// 更新兑换状态
export const updateExchangeStatus = (params) => {
  return request({
    url: `/points/goods/exchange/status`,
    method: 'put',
		params
  });
};

// 导出积分商品兑换记录
export const exportPointsExchange = (status) => {
  return request({
    url: '/points/goods/exchange/export',
    method: 'get',
    params: { status },
    responseType: 'blob' // 用于文件下载
  });
};

// 积分商品兑换状态枚举
export const PointsGoodsExchangeStatus = {
  PENDING: 'PENDING',           // 待处理
  APPROVED: 'APPROVED',         // 已处理
  // SHIPPING: 'SHIPPING',         // 发货中
  // SHIPPED: 'SHIPPED',           // 已发货
  COMPLETED: 'COMPLETED',       // 已完成
  CANCELLED: 'CANCELLED',       // 已取消
  REJECTED: 'REJECTED'          // 已拒绝
};

// 积分商品兑换状态标签映射
export const PointsGoodsExchangeStatusLabels = {
  [PointsGoodsExchangeStatus.PENDING]: '待处理',
  [PointsGoodsExchangeStatus.APPROVED]: '已处理',
  // [PointsGoodsExchangeStatus.SHIPPING]: '发货中',
  // [PointsGoodsExchangeStatus.SHIPPED]: '已发货',
  [PointsGoodsExchangeStatus.COMPLETED]: '已完成',
  [PointsGoodsExchangeStatus.CANCELLED]: '已取消',
  [PointsGoodsExchangeStatus.REJECTED]: '已拒绝',
};